﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Zero.Service;

namespace Zero.Web.Controllers
{
    public class AccountController : BaseController
    {
        private readonly ISystemService systemService;
        public AccountController(ISystemService systemService)
        {
            this.systemService = systemService;
        }
        public AccountController()
        { }
        //
        // GET: /Account/
        
        public bool ValidateLogin()
        {
            var context = System.Web.HttpContext.Current;
            string username = context.Request.Params["username"];
            string password = context.Request.Params["password"];

            return systemService.UserLogin(username, password) ? true : false;
        }
        [HttpPost]
        public ActionResult LoginOn()
        {
            return  Json(ValidateLogin().ToString());
        }
        public ActionResult Index()
        {
            return  View();
        }
        
        public ActionResult Login()
        {
            return View();
        }
        //
        // GET: /Account/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /Account/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Account/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Account/Edit/5

        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /Account/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Account/Delete/5

        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /Account/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
